#ifndef __PIPEHPP__
#define __PIPEHPP__
#include <iostream>
#include <functional>
#include <vector>
#include <queue>

#include <cstdlib>
#include <cstdio>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>

using namespace std;

class chunnels {
public:
    struct mycmp {
        bool operator()(const chunnels& e1, const chunnels& e2) const {
            return e1._cnt > e2._cnt;
        }
    };
    chunnels(int fd, int id, const string& name) 
        :_fd(fd), _id(id), _processName(name), _cnt(0) 
    {}
    int _fd;
    pid_t _id;
    string _processName;
    //记录当前子进程被调用的次数
    //负载因子
    //使用优先级队列组织
    //保证每个进程平均下来调用次数相当
    int _cnt;
};

vector<function<void()>> vtasks;

function<void()> task1 = []() {
    cout << "任务1" << endl;
};
function<void()> task2 = []() {
    cout << "任务2" << endl;
};
function<void()> task3 = []() {
    cout << "任务3" << endl;
};
function<void()> task4 = []() {
    cout << "任务4" << endl;
};
function<void()> task5 = []() {
    cout << "任务5" << endl;
};

void LoadTasks() {
    vtasks.push_back(task1);
    vtasks.push_back(task2);
    vtasks.push_back(task3);
    vtasks.push_back(task4);
    vtasks.push_back(task5);
}
#endif